//HJ55 挑7

#include <stdio.h>
int main()
{
    int n = 0;
    scanf("%d", &n);
    int count = 0;
    for(int i = 6; i <= n; i++)
    {
        int m = i;
        while(m)
        {
            int b = m % 10;
            m /= 10;
            if(7 == b || 7 == m || i % 7 == 0)
            {
                count++;
                break;
            }
        }
    }  
    printf("%d\n", count); 
}